package com.yazi.mxz.mobile.controller;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.myframework.smhj.common.exception.MyException;
import com.myframework.smhj.jackson.result.StatusResult;
import com.yazi.mxz.common.entity.beans.Feedback;
import com.yazi.mxz.common.service.FeedbackService;

@Controller("feedbackContoller")
@RequestMapping("/feedback")
public class FeedbackController extends BaseController {
	private static Logger log = LoggerFactory.getLogger(FeedbackController.class);
	
	@Resource
	FeedbackService feedbackService;
	

	@RequestMapping
	public String index() {
		log.debug("进入意见反馈页面");
		return "v1.5/feedback_add";
	}
	
	@RequestMapping("/addDo/json")
	@ResponseBody
	public StatusResult listJson(Feedback feedback, HttpServletRequest req) {
		log.debug("添加反馈意见");
		StatusResult jsonResult = new StatusResult();
		try {
			feedback.setIp(req.getRemoteAddr());
			feedbackService.add(feedback);
			jsonResult.setOk();
		} catch (MyException e) {
			jsonResult.setFailMessage(e.getMessage());
		} catch (Exception e) {
			log.error("添加反馈意见时异常：", e);
			jsonResult.setErrorMessage("提交失败");
		}
		return jsonResult;
	}
}
